package com.op.studyingliteapp.fragment.resource;

import java.util.ArrayList;

import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ListView;
import android.widget.Toast;

import com.op.studyingliteapp.R;
import com.op.studyingliteapp.activity.PPTActivity;
import com.op.studyingliteapp.fragment.pptresource.PPTResourceFragment;
import com.op.util.ScreenSendUtils;

/**
 * @author handsome
 */
public class ResourceFragment extends Fragment {

    private ListView resourceListView;
    private View view;

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
         view = inflater.inflate(R.layout.fragment_resource, container,
                false);
        ArrayList<ResourceCellData> list = new ArrayList<ResourceCellData>();
        resourceListView = (ListView) view.findViewById(R.id.resource_listview);
        resourceListView.setOnItemClickListener(listener);
        ResourceListAdapter resourceListAdapter = new ResourceListAdapter(
                getActivity(), list);
        resourceListView.setAdapter(resourceListAdapter);

        return view;
    }

    OnItemClickListener listener = new OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position,
                                long id) {
            if (position == 0) {
                Intent intent = new Intent(getActivity(), PPTActivity.class);
                startActivity(intent);
            } else {
                Toast.makeText(getActivity(), "待开发" + position, Toast.LENGTH_SHORT).show();

            }

        }
    };

    @Override
    public void onResume() {
        super.onResume();

    }
}
